package com.atguigu.controller;

import com.atguigu.service.SecondKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LOGIN
 * @title HelloController
 * @create 2025/6/16 18:56
 * @description
 */
@RestController
@RequestMapping("hello")
public class HelloController {
    /**
     * 秒杀：
     *         1、redis中保存商品的库存(  sec:skuId:1001  1000 )
     *        2、业务：
     *            用户提交秒杀请求时，判断库存是否足够
     *          如果足够： 库存-1 同步到redis中
     *               如果不足够：秒杀失败
     */

    @Autowired
    SecondKillService secondKillService;

    @GetMapping("secondKill/{skuId}")
    public String secondKill(@PathVariable("skuId") String skuId){
        return secondKillService.secondkill(skuId);

    }
}
